{extend name="./oscshop/admin/view/public/base.html" /}
{block name="content"}
<div class="page-header">
	<h1>	
		{$breadcrumb1}
		<small>
			<i class="ace-icon fa fa-angle-double-right"></i>
			{$breadcrumb16}
		</small>
	</h1>
</div>

	
<table class="table table-striped table-bordered table-hover search-form">
	<thead>
	<tr>
		<th>
			<input name="user_name" type="text" placeholder="输入会员手机号码" value="{:input('param.user_name')}" />
			&nbsp;&nbsp;
			合约开始时间段<input name="begin_day" type="date" placeholder="输入开始时间" value="{:input('param.begin_day')}" />
			—<input name="begin_day2" type="date" placeholder="输入开始时间" value="{:input('param.begin_day2')}" />
			&nbsp;&nbsp;
			合约结束时间段<input name="end_day" type="date" placeholder="输入开始时间" value="{:input('param.end_day')}" />
			—<input name="end_day2" type="date" placeholder="输入开始时间" value="{:input('param.end_day2')}" />
			&nbsp;&nbsp;
			<select name="exchange_id" id ="exchange_id"   tabindex="4">
				<option value ="">请选择交易所</option>
				{volist name="exchange" id="p" empty="$exchange"}
				<option value ="{$p.id}" {if condition="$p.id eq input('exchange_id')"} selected="selected" {/if}>{$p.name}</option>
				{/volist}
			</select>

			<select name="variety_id" id ="variety_id"   tabindex="4">
				<option value ="">请选择交易品种</option>
			</select>
			&nbsp;&nbsp;
			<select name="s_state" id="s_state">
				<option value="">卖出凭证状态</option>
				<option value="1" {if condition="1 eq input('s_state')"} selected="selected" {/if}>是</option>
				<option value="0" {if condition="0 eq input('s_state') and input('s_state') neq ''"} selected="selected" {/if}>否</option>
			</select>
			&nbsp;&nbsp;
			<a class="btn btn-primary search" href="javascript:;" url="{:url('Free/list_free')}">查询</a>
			<a class="btn btn-primary" href="{:url('Free/list_free')}" >清空查询</a>
			<a class="btn btn-primary search" href="javascript:;" url="{:url('Free/export_carried')}" >导出</a>
		</th>
	</tr>
	</thead>
</table>	
	
<div class="row">
	<div class="col-xs-12">	
		<div class="table-responsive">
			<span>抵扣金豆额：{$sum1}</span>&nbsp;&nbsp;&nbsp;
			<span>抵扣元宝额：{$sum2}</span>&nbsp;&nbsp;&nbsp;
			<span>总申总额：{$sum3}</span>&nbsp;&nbsp;&nbsp;
			<span>买入总枚数：{$b_num}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<span>买入总价格：{$b_price}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<span>卖出总枚数：{$s_num}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<span>卖出总价格：{$s_price}</span>
			<p></p>
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
					    <th>ID</th>
						<th>用户</th>
						<th>姓名</th>
						
						<th>合约开始时间</th>
						<th>合约结束时间</th>
						<th>交易所</th>
						
						<th>交易品种</th>
						<th>申请金额</th>
						<th>抵扣金豆</th>
						<th>买入枚数</th>
						<th>买入总价</th>
						<th>买入单价</th>
						<th>卖出枚数</th>
						<th>卖出总价</th>
						<th>卖出预估单价</th>
						<th>是否提交卖出凭证</th>

					</tr>
				</thead>
				<tbody>
						{volist name="list" id="v"}
						<tr>						
							<td>{$v.id}</td>
							<td>{$v.username}</td>
							<td>{:get_member_idcardname($v.username)}</td>
							<td>{$v.begin_day}</td>
							<td>{$v.end_day}</td>
							<td>{:get_trade_name($v.exchange)}</td>
							<td>{:get_variety_name($v.exchange_variety)}</td>
							<td>{$v.money}</td>
							<td>{$v.price}</td>
							<td>{$v.b_num}</td>
							<td>{$v.b_price}</td>
							<td>{if condition="$v.b_price eq 0"}0{else}{$v.b_price/$v.b_num}{/if}</td>
							<td>{$v.s_num}</td>
							<td>{$v.s_price}</td>
							<td>{if condition="$v.b_price eq 0"}0{else}{$v.b_price*1.3/$v.b_num}{/if}</td>
							<td>{if condition="$v.s_state eq 1"}是{elseif condition="$v.s_state eq 0"}否{/if}</td>
						</tr>
						{/volist}	
				</tbody>
			</table>
			{$page}
		</div>
	</div>
</div>
<div id="outerdiv" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;">
	<div id="innerdiv" style="position:absolute;">
		<img id="bigimg" style="border:5px solid #fff;" src="" />
	</div>
</div>
{/block}
{block name="javascript"}
<script>
	$(function(){
		$(".search").click(function () {
			var url = $(this).attr('url');
			var query = $('.search-form').find('input,select').serialize();
			query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
			query = query.replace(/^&/g, '');
			if (url.indexOf('?') > 0) {
				url += '&' + query;
			} else {
				url += '?' + query;
			}
			window.location.href = url;
		});
	});
</script>
<script type="text/javascript">
	$('#exchange_id').change(function(){
		var iframe_array = <?php echo  json_encode($variety);   ?>;
		var checkValue=jQuery("#exchange_id").val();
		$("#variety_id").empty();
		for (var i = 0; i <iframe_array.length ; i++)
		{
			if(iframe_array[i]['exchange_id']==checkValue)
			{
				var opt = "<option value='"+iframe_array[i]['id']+"'>"+iframe_array[i]['name']+"</option>";
				jQuery("#variety_id").append(opt);
			}
		}

	})
</script>
<script>
	function repulse(id){
		var judge = prompt("审批意见，可不填");
		if (judge) {
			$.ajax({
				type:'post',
				data:{id:id,remark:judge},
				url:"confirm_repulse",
				success:function(data){
					alert(data.msg);
				}
			});
		}
	}
</script>
<script>	
$(function(){
   $("#search").click(function () {
        var url = $(this).attr('url');
        var query = $('.search-form').find('input,select').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
        query = query.replace(/^&/g, '');
        if (url.indexOf('?') > 0) {
            url += '&' + query;
        } else {
            url += '?' + query;
        }
        window.location.href = url;
    });	
});
</script>
<script type="text/javascript">
	//图片预览
	$('.image').click(function(){
		var _this = $(this);							//将当前的pimg元素作为_this传入函数
		imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);

	});
	function imgShow(outerdiv, innerdiv, bigimg, _this) {
		var src = _this.attr("src");					//获取当前点击的pimg元素中的src属性
		$(bigimg).attr("src", src);						//设置#bigimg元素的src属性

		/*获取当前点击图片的真实大小，并显示弹出层及大图*/
		$("<img/>").attr("src", src).load(function () {
			var windowW = $(window).width();			//获取当前窗口宽度
			var windowH = $(window).height();			//获取当前窗口高度
			var realWidth = this.width;					//获取图片真实宽度
			var realHeight = this.height;				//获取图片真实高度
			var imgWidth, imgHeight;
			var scale = 0.8;							//缩放尺寸，当图片真实宽度和高度大于窗口宽度和高度时进行缩放

			if (realHeight > windowH * scale) {			//判断图片高度
				imgHeight = windowH * scale;			//如大于窗口高度，图片高度进行缩放
				imgWidth = imgHeight / realHeight * realWidth;		//等比例缩放宽度
				if (imgWidth > windowW * scale) {					//如宽度扔大于窗口宽度
					imgWidth = windowW * scale;						//再对宽度进行缩放
				}
			} else if (realWidth > windowW * scale) {				//如图片高度合适，判断图片宽度
				imgWidth = windowW * scale;							//如大于窗口宽度，图片宽度进行缩放
				imgHeight = imgWidth / realWidth * realHeight;		//等比例缩放高度
			} else {									//如果图片真实高度和宽度都符合要求，高宽不变
				imgWidth = realWidth;
				imgHeight = realHeight;
			}
			$(bigimg).css("width", imgWidth);			//以最终的宽度对图片缩放

			var w = (windowW - imgWidth) / 2;			//计算图片与窗口左边距
			var h = (windowH - imgHeight) / 2;			//计算图片与窗口上边距
			$(innerdiv).css({"top": h, "left": w});		//设置#innerdiv的top和left属性
			$(outerdiv).fadeIn("fast");					//淡入显示#outerdiv及.pimg
		});
		$('#outerdiv').click(function () {				//再次点击淡出消失弹出层
			$(this).fadeOut("fast");
		});
	}
</script>
{/block}